package com.example.budget3.months;

import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;

public class DeleteDialogFragment extends DialogFragment {
	
	public static final String KEY_LIST_PREFERENCE = "pref_currency";
	public static final String POSITION_ARG = "position";
	private int position;
	private ListFragment parentFragment;
	@Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {

        getActivity().getLayoutInflater();
    	
    	position = getArguments().getInt(POSITION_ARG);
    	
    	AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    	parentFragment = (ListFragment) getTargetFragment();

    	AlertDialog dialog = builder.setMessage("Are you sure you want to remove this item?")
		.setTitle("Remove Item")
		.setNegativeButton("Cancel", null)
		.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
			public void onClick(DialogInterface dialog, int id) {
				 parentFragment.removeItem(position);
			}
		}).create();
    	
		dialog.show();
	
		return dialog;
    }

}
